import NodeRSA from "encrypt-rsa";


export function decodeByPublicKey(encryptedString) {
  const publicK = `-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAy66HMtsBJOfTUhgpSFI+
upFGbsPRKG2GKZKWkc3isJJEZ+Npx8Rf75FJ12zSiN9Y2KvC0Wtl0gZh2o3yDrdv
CN+MgFElBhWtAHiRygAP0mUSCrrliXyK8RqLiMHhitNwk70qfrAZDARIPKZmZVEZ
33SvJBy5Al+rYFI/CssHwS+XGnx2xq++RE47K148WxpqvVJ7nM3sve/JYFh8oFwS
uKZ7eSmgmf3qImIL9Ye/ZfA5igmWiS98NTM5YIcqzBlmo+WJeShJy1b+xe53qcAf
tT50M/Kyfox32ahbTXT6VdX7kDArBTSAfHyzHfSrHoFI+UuMIXls5b+qe5vh6u/K
RwIDAQAB
-----END PUBLIC KEY-----
`
  const key = new NodeRSA(publicK.toString(), "", 2048);
  const decryptedString = key.decrypt({ text: encryptedString, publicKey: publicK.toString() });
  return decryptedString
}
